<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>同城活动</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link href="../../plugins/mui/mui.min.css" rel="stylesheet" />
    <style>
        body{
            font-family: "Microsoft YaHei", sans-serif;
            min-height:100vh;
            background: #fff;
        }
        .header{
            background: #2a2c33;
        }
        .header h1{
            color:#fff;
            font-size:18px;
        }
        .header a{
            color:#fff;
        }
        .left{
            float:left;
        }
        .right{
            float:right;
        }
        .clear{
            clear: both;
            display:table;
        }
        ul li{
            list-style-type: none;
        }
        .section{
            margin-top:44px;
        }
        .intro .view{
            width:100%;
            position: relative;
        }
        .view img{
            width:100%;
            height:32vh;
        }
        .view p{
            margin:0;
            width:100%;
            color:#fff;
            height:35px;
            line-height:35px;
            font-size:15px;
            padding-left:12px;
            background:rgba(0,0,0,0.5);
            position: absolute;
            bottom:4px;
            left:0;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp:1;
            overflow: hidden;
        }
        /*报名*/
        .apply{
            padding:0 12px;
        }
        .apply div{
            border-bottom:1px solid #f2f2f2;
            margin-top:6px;
        }
        .apply .textarea{
            border:none;
        }
        .apply form label{
            font-size:14px;
            color:#333;
            display: inline-block;
            width:15%;
            /*vertical-align: top;*/
            /*line-height: 2.5;*/

            vertical-align: middle;
        }
        .apply form div:last-child label{
            vertical-align: top;
            line-height: normal;
        }
        .apply div:last-child{
            border:none;
        }
        .apply form div textarea{
            border:none;
            color:#999;
            display: inline-block;
            width:80%;
            padding:0;
            margin:0;
            border:1px solid #f2f2f2;
            height:120px;
            word-break:break-all;
        }
        .apply form input{
             border:none;
             color:#999;
             display: inline-block;
             width:80%;
             padding:0;
             margin:0;
             font-size:15px;
         }
        .apply .btn{
            width:100%;
            color:#fff;
            background: #43AC45;
            border:none;
            height:40px;
            margin:30px 0;
            font-size:15px;
        }
        /*备注*/
       .remark{
       		width:100%;
       		position:absolute;
       		top:63%;
       		text-align: center;
       		display: none;
       }
       .remark p{
       		display: inline-block;
       		background: rgba(0,0,0,.5);
       		color:#fff;
       		padding:6px 12px;
       		border-radius: 3px;
       }
       textarea{
       	font-size:14px;
       }
       
    </style>
</head>
<body>
<header class="mui-bar mui-bar-nav header">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">活动报名</h1>
</header>
<div class="section">
    <!--景点简介-->
    <div class="intro">
        <div class="view">
            <!--<img src="../../images/ce1.jpg" alt="">
            <p>五一相约深山沟农场五一相约深山沟农场五一相约深山沟农场五一相约深山沟农场五一相约深山沟农场</p>-->
        </div>

    </div>
    <div class="apply">
        <form>
            <div>
                <label >姓名：</label>
                <input id="user_name" type="text" name="name" placeholder="请输入姓名">
            </div>
            <div>
                <label>电话：</label>
                <input id="user_mobile" type="tel" name="tell" placeholder="请输入电话">
            </div>
            <div class="textarea">
                <label>备注：</label>
                <textarea id="remark" placeholder="0-100字以内(可不填写)" maxlength="100"></textarea>
            </div>
        </form>
		<button class="btn">提交</button>
    </div>
	<!--备注-->
	<div class='remark'>
		<p>您已报名，请勿重复提交</p>
	</div>
		
</div>

    <script src="../../plugins/mui/mui.min.js"></script>
    <script src="../../plugins/jquery/jquery-3.1.0.min.js"></script>
    <script src="../../js/getApiToken.js"></script>
    <script src="../../js/md5.js"></script>
    <script>
        mui.init();
        mui.plusReady(function(){
            var uid=plus.storage.getItem('cg_user_id');
            var activity=plus.webview.currentWebview().this_id;
            var name=plus.webview.currentWebview().name;
            var path=plus.webview.currentWebview().path;
            console.log(name+path);
            console.log(uid);
            console.log(activity);

            //图片展示部分
            var view='<img src="'+path+'" alt="">'+
                    '<p>'+name+'</p>';
            $('.view').append(view);
            //备注长度限制
            mui('.apply').on('keydown','textarea',function(){
                if($('#remark').val().length>=100){
                    mui.alert('备注不得超过一百字')
                }
            });

            //提交报名活动
            $('.apply').off('tap').on('tap','.btn',function(e){
                //获取提交数据===去除空格
                var user_name=$('#user_name').val().replace(/\s/g,"");
                var user_mobile=$('#user_mobile').val().replace(/\s/g,"");
                var remark=$('#remark').val().replace(/\s/g,"");
                console.log(user_mobile.length);
                console.log(user_name);
                console.log($('#remark').val());
                console.log($('#remark').val().length)
//				console.log(user_name+'--'+uid+'--'+user_mobile+'--'+remark+'--'+activity);
                //列表获取ajax
                if(user_name==''){
                    mui.alert('请输入您的姓名')
                }else if(user_mobile==''){
                    mui.alert('请输入您的电话')
                }else if(user_mobile.length!=11){
                    mui.alert('输入号码格式有误')
                }else if($('#remark').val().length>100){
                    mui.alert('备注限制在0-100字以内！')
                }else{
                    myAjax('home/Activity/getEnroll','post',
                            {
                                'user_name':user_name,
                                'user_mobile':user_mobile,
                                'remark':remark,
                                'uid':uid,
                                'activity_id':activity
                            },
                            function(data) {
                                console.log(JSON.stringify(data));
                                console.log('活动报名');
                                if (JSON.stringify(data)==1) {
                                	//关闭详情页 
	                            	var detailView = plus.webview.getWebviewById("activity_apply");
	                            	detailView.close();
                                    mui.openWindow({
                                        url: 'apply_put.html',
                                        id: 'apply_put',
                                        waiting: {
                                            autoShow: true,//自动显示等待框，默认为true
                                            title: '正在加载...',//等待对话框上显示的提示内容
                                        },
                                        show: {
                                            autoShow: true,
                                            aniShow: 'fade-in'
                                        },
                                        extras: {
                                            type: 0
                                        }
                                    });
                                    $('input').val('');
                                    $('textarea').val('');
                                } else {
                                    mui.alert('报名失败');
                                    $('input').val('');
                                    $('textarea').val('');
                                }
                            }
                    )
                }

            })
        })
    </script>
</body>
</html>
